/**
 * 注册相关类型定义
 */
import type { ApiResponse } from './api'

// 用户角色枚举
export enum UserRole {
  ADMIN = 'admin',
  PROJECT_MANAGER = 'project_manager',
  DEVELOPER = 'developer',
  TESTER = 'tester',
  VIEWER = 'viewer'
}

// 用户状态枚举
export enum UserStatus {
  ACTIVE = 'active',     // 激活
  INACTIVE = 'inactive', // 禁用
  DELETED = 'deleted'    // 已删除（前端不显示）
}

// 注册请求参数
export interface RegisterParams {
  username: string
  name: string
  email: string
  password: string
  department?: string
  position?: string
  phone?: string
  avatar?: string
  bio?: string
  roles: UserRole[]
}

// 注册响应用户数据
export interface RegisterUserData {
  id: string
  name: string
  email: string
  department?: string
  position?: string
  phone?: string
  avatar?: string
  status: UserStatus
  is_verified: boolean
  roles: UserRole[]
  permissions: string[]
  created_at?: string
  updated_at?: string
  last_login?: string
}

// 注册响应数据
export type RegisterResponse = ApiResponse<RegisterUserData>

// 表单验证规则
export interface RegisterFormRules {
  username: Array<{
    required?: boolean
    message: string
    trigger?: string
    min?: number
    max?: number
    pattern?: RegExp
  }>
  name: Array<{
    required?: boolean
    message: string
    trigger?: string
    min?: number
    max?: number
  }>
  email: Array<{
    required?: boolean
    message: string
    trigger?: string
    type?: string
  }>
  password: Array<{
    required?: boolean
    message: string
    trigger?: string
    min?: number
    validator?: (rule: any, value: any, callback: any) => void
  }>
  confirmPassword: Array<{
    required?: boolean
    message: string
    trigger?: string
    validator?: (rule: any, value: any, callback: any) => void
  }>
  department: Array<{
    required?: boolean
    message: string
    trigger?: string
  }>
  position: Array<{
    required?: boolean
    message: string
    trigger?: string
  }>
  phone: Array<{
    required?: boolean
    message: string
    trigger?: string
    pattern?: RegExp
  }>
}

// 注册表单数据
export interface RegisterFormData {
  username: string
  name: string
  email: string
  password: string
  confirmPassword: string
  department: string
  position: string
  phone: string
  roles: UserRole[]
  agreement: boolean
}